﻿using System;
using System.Windows.Data;

namespace MyAnimelistRecommender.Converter
{
    public class MultiplicationConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                var val1 = System.Convert.ToDecimal(value);
                var val2 = System.Convert.ToDecimal(parameter.ToString().Replace("{", "").Replace("}", ""), System.Globalization.CultureInfo.InvariantCulture);
                return val2 * val1;
            }
            catch (Exception)
            {
                return value;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}